package com.loong.user.handler;

import com.loong.common.domain.BaseQuery;
import com.loong.common.domain.Pager;
import com.loong.common.utils.ResultUtils;
import com.loong.common.utils.TransformUtils;
import com.loong.user.business.ManageAdminBusiness;
import com.loong.user.common.backend.param.ManageAdminParam;
import com.loong.user.common.backend.param.ManageAdminQueryParam;
import com.loong.user.common.backend.result.ManageAdminResult;
import com.loong.user.model.ManageAdmin;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import tk.mybatis.mapper.util.Assert;

import javax.annotation.Resource;

/**
 * @Description: 系统后台用户服务
 * @Author: hzp
 * @Date: 2020-10-16 9:47
 */
@Component
public class ManageAdminHandler {
    @Resource
    private ManageAdminBusiness manageAdminBusiness;
    /**
     * 保存系统后台用户
     * @param param
     */
    public void save(ManageAdminParam param){
        manageAdminBusiness.save(TransformUtils.transform(param, ManageAdmin.class));
    }

    /**
     * 更新系统后台用户
     * @param param
     */
    public void update(ManageAdminParam param){
        manageAdminBusiness.updateByPrimaryKeySelective(TransformUtils.transform(param, ManageAdmin.class));
    }

    /**
     *根据id删除系统后台用户
     * @param id 用户的id
     */
    public void deleteById(Long id){
        manageAdminBusiness.deleteById(id);
    }
    /**
     * 分页查询
     * @param baseQuery
     * @param param
     * @return
     */
    public Pager<ManageAdminResult> pageQuery(BaseQuery baseQuery, ManageAdminQueryParam param){
        Pager<ManageAdmin> manageApisPager = manageAdminBusiness.pageQuery(baseQuery, () -> manageAdminBusiness.query(param));
        return TransformUtils.transformPage(manageApisPager, ManageAdminResult.class);
    }


}
